home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 01 / b_constr.c < prev    next >
Text File  |  1990-10-31  |  674b  |  28 lines

  1. /* b_construct.c -- Listing 3. */
  2.  
  3. #include <stdlib.h>
  4. #include "textbuf.h"
  5.  
  6. PUBLIC textbuf *b_construct( textbuf *b, int nrows, int ncols )
  7. {
  8.     /* Initialize a textbuf, Return b on success, NULL on failure */
  9.  
  10.     bufsize asize = nrows * ncols;
  11.  
  12.     if( asize >= MAXBSIZE )          /* Won't fit in an 8086 segment */
  13.         b = NULL;
  14.     else if( !(b->buf = BMALLOC(asize)) )  /* get the actual buffer */
  15.         b = NULL;
  16.     else
  17.     {
  18.         b->nrows = nrows;
  19.         b->ncols = ncols;
  20.         b->row   = 0;
  21.         b->col   = 0;
  22.         b->p     = b->buf;
  23.         b_clearbuf( b, ' ' );
  24.         b->magic = B_MAGIC;
  25.     }
  26.     return b;
  27. }
  28.